package router

import (
	"golang_start/app/api/controller"
	"golang_start/app/api/controller/createfile"
	"golang_start/common"
	"golang_start/common/aliyunoss"
	"net/http"

	"github.com/gin-gonic/gin"
)

func ApiRouter(g *gin.Engine) {
	/*引入静态资源*/
	// g.Static("/static", "./static")
	g.StaticFS("/static", http.Dir("./static"))
	g.StaticFS("/upload", http.Dir("./upload"))

	g.GET("/hello", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "Hello world2s2-----bbbbbbb-2222!",
		})
	})
	/*文件上传*/
	g.POST("uploadfile", common.Upload_file)
	g.POST("uploadfiles", common.Upload_files)
	g.GET("autograph", aliyunoss.AutographG)
	g.POST("autograph", aliyunoss.AutographP)
	g.NoRoute(func(c *gin.Context) {
		c.String(http.StatusNotFound, "404 not found")
	})
	/*静态文件-包含目录*/

	Zz := g.Group("/createfile")
	{
		Zz.GET("/index", createfile.Index)
		Zz.POST("/create", createfile.Create)
		Zz.GET("/getcloumn", createfile.Cloumn)
	}

	Code_type := g.Group("/api/code_type")
	{

		Code_type.POST("/add_", (&controller.CodeType{}).Add_)
		Code_type.POST("/delete_", (&controller.CodeType{}).Delete_)
		Code_type.POST("/update_", (&controller.CodeType{}).Update_)
		Code_type.GET("/list_", (&controller.CodeType{}).List_)
		Code_type.GET("/catelist_", (&controller.CodeType{}).Catelist_)
		Code_type.GET("/detail_", (&controller.CodeType{}).Detail_)
	}
	Code_content := g.Group("/api/code_content")
	{
		Code_content.POST("/add_", (&controller.CodeContent{}).Add_)
		Code_content.POST("/delete_", (&controller.CodeContent{}).Delete_)
		Code_content.POST("/update_", (&controller.CodeContent{}).Update_)
		Code_content.GET("/list_", (&controller.CodeContent{}).List_)
		Code_content.GET("/detail_", (&controller.CodeContent{}).Detail_)

		// Code_content.GET("/search_data", (&controller.CodeContent{}).SearchData)

	}

	Code_activity_testa := g.Group("/code_activity_testa")
	{
		Code_activity_testa.POST("/add_", (&controller.CodeActivityTesta{}).Add_)
		Code_activity_testa.POST("/delete_", (&controller.CodeActivityTesta{}).Delete_)
		Code_activity_testa.POST("/update_", (&controller.CodeActivityTesta{}).Update_)
		Code_activity_testa.GET("/list_", (&controller.CodeActivityTesta{}).List_)
		Code_activity_testa.GET("/detail_", (&controller.CodeActivityTesta{}).Detail_)
	}

	/*{%routes%}*/

	// Up := g.Group("/upload")
	// {
	// 	Up.POST("/file", upload.UploadController{}.AddUpload)
	// 	Up.GET("/ossupload", upload.UploadController{}.OssUpload)
	// 	Up.POST("/ossCallback", upload.UploadController{}.OssCallback)
	// }

}
